package com.mmp.main.servlet.report;

import java.io.IOException;
import java.util.HashMap;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mmp.common.servlet.BasicServlet;
import com.mmp.main.entity.HospitalDevice;
import com.mmp.main.util.Default;
import com.mmp.main.util.Enums;
import com.mmp.main.util.WebUtil;

public class ViewDeviceProfile extends BasicServlet {

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		HospitalDevice device = (HospitalDevice) request.getAttribute(Default.DEVICE_INFO_ATTR_NAME);

		String deviceDetailsReportUrl = "http://" + Default.APP_SERVER_IP + Default.APP_CONTEXT
				+ "/ViewDeviceDetailsReport?deviceCode=" + device.getCode();

		HashMap params = new HashMap();
		// pass table datasource as parameter
		params.put(Default.REPORT_TITLE_PARAM_NAME, Enums.REPORT_TITLE.DEVICE_ACCESSORIES.getReportTitle());
		params.put("device", device);
		params.put("deviceStatus", WebUtil.getDeviceStatusName(device));
		params.put("deviceDetailsReportUrl", deviceDetailsReportUrl);
		viewPDFReport("rt5.jasper", null, params, request, response);
	}
}
